from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_script import Manager
import os
from common.libs.UrlManager import UrlManager


# 程序入口文件
class Application(Flask):
    def __init__(self, import_name, template_folder=None, root_path=None):
        super(Application, self).__init__(import_name, static_folder=None)
        # 加载配置文件
        self.config.from_pyfile('config/base_setting.py')
        self.config['JSON_AS_ASCII'] = False

        db.init_app(self)


db = SQLAlchemy()
app = Application(__name__)

manager = Manager(app)

'''
函数模板
'''

app.add_template_global(UrlManager.buildStaticUrl, 'buildStaticUrl')
app.add_template_global(UrlManager.buildUrl, 'buildUrl')
